-
Notifications
You must be signed in to change notification settings - Fork 0
Support LLVM raw profile versions 8, 9, and 10 #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Saman Dehghan <samaan.dehghan@gmail.com>
| #endif | ||
| .names_size = END_NAMES - START_NAMES, | ||
| .counters_delta = (uintptr_t)START_COUNTERS, | ||
| .names_delta = (uintptr_t)START_NAMES, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why (uintptr_t) is removed? On my side this does not compile with either GCC or Clang
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's focus on #2 , I just put this here as a record for a version before adding clang-11 to clang-13 support. ignore this PR.
|
|
My steps of x86 testing, starting with a fresh Debian bookworm VM
## Dependencyies
sudo apt install build-essential libncurses-dev flex bison \
kconfig-frontends-nox python3-dev acpica-tools uuid-dev pkgconf libglib2.0-dev \
libpixman-1-dev libyajl-dev python3-venv ninja-build \
lsb-release wget software-properties-common gnupg
wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh
chmod +x /tmp/llvm.sh
sudo /tmp/llvm.sh 20
rm /tmp/llvm.sh
## Build Xen
# git clone git@github.com:enum-class/xen.git --branch V3 --depth=10 xen-source
git clone https://github.com/whentojump/xen.git --branch V3-wentao --depth=10 xen-source
cd xen-source
LLVM_DIR=/lib/llvm-20/bin
# ❓ I don't actually know whether we need them all or just CC
MAKE_FLAGS=(
"CC=$LLVM_DIR/clang"
# "LD=$LLVM_DIR/ld.lld"
# "AR=$LLVM_DIR/llvm-ar"
# "NM=$LLVM_DIR/llvm-nm"
# "STRIP=$LLVM_DIR/llvm-strip"
# "OBJCOPY=$LLVM_DIR/llvm-objcopy"
# "OBJDUMP=$LLVM_DIR/llvm-objdump"
# "READELF=$LLVM_DIR/llvm-readelf"
# "HOSTCC=$LLVM_DIR/clang"
# "HOSTCXX=$LLVM_DIR/clang++"
# "HOSTAR=$LLVM_DIR/llvm-ar"
# "HOSTLD=$LLVM_DIR/ld.lld"
)
# "--libdir=/lib/x86_64-linux-gnu/" makes life easier rather than the
# default /usr/local/lib and LD_LIBRARY_PATH hassle
./configure --disable-xen --disable-docs --libdir=/lib/x86_64-linux-gnu/
# Build "tools" only with GNU
# ❓ This step builds a xen anyway under "tools/firmware/xen-dir/xen-root/xen". What is it?
make -j$(nproc) dist-tools
sudo make -j$(nproc) install-tools
# Build "xen" only with Clang/LLVM
make ${MAKE_FLAGS[@]} -C xen defconfig
pushd xen
kconfig-tweak -d LIVEPATCH
kconfig-tweak -e COVERAGE
popd
make ${MAKE_FLAGS[@]} -C xen olddefconfig
make ${MAKE_FLAGS[@]} -j$(nproc) efi-y= dist-xen
sudo make ${MAKE_FLAGS[@]} -j$(nproc) efi-y= install-xen
## Prepare for the next boot
# I don't have easy access to my VM's GRUB screen so this
# is the only way for me to select Xen as boot target.
# It's somewhat good as it's noninteractive.
# But proceed with caution and carefully consider what string
# should be put here in your setup. E.g., run
# "sudo grep menuentry /boot/grub/grub.cfg | less"
#
# sudo sed -i 's|GRUB_DEFAULT=0|GRUB_DEFAULT="Debian GNU/Linux, with Xen hypervisor"|' /etc/default/grub
#
sudo update-grub
sudo reboot
## After reboot
# ❓ I don't know why only I need this (not you or Erkai :))). Otherwise I have
# "xencall: error: Could not obtain handle on privileged command interface: No such file or directory
# xencov: opening xc interface: No such file or directory"
sudo systemctl start xencommons.service
sudo systemctl enable xencommons.service
sudo xencov read | tee >/dev/null default.profraw
file default.profraw
/lib/llvm-20/bin/llvm-profdata merge default.profraw -o default.profdata
file default.profdata
# Replace it with your path
XEN_SOURCE_DIR=/vagrant/xen-source/
TMP_REPORT_DIR=`mktemp -d`
/lib/llvm-20/bin/llvm-cov show \
-instr-profile default.profdata \
-output-dir $TMP_REPORT_DIR \
-show-directory-coverage \
-show-branches=count \
-use-color=false \
$XEN_SOURCE_DIR/xen/xen-syms
less $TMP_REPORT_DIR/index.txt
less $TMP_REPORT_DIR/coverage/$XEN_SOURCE_DIR/xen/common/coverage/llvm.c.txt
rm -r $TMP_REPORT_DIR |
|
One more note on linking, related to some of my previous comments/questions: If LD is GNU linker (both your and my current way), there is a sensible delay around On the other hand, if I additionally use LLVM linker as well MAKE_FLAGS=(
"CC=$LLVM_DIR/clang"
"LD=$LLVM_DIR/ld.lld"
)
|
|
Allow me to cc @erkaii as well to see if he has some insights. But no obligation. Thanks! |
I also see this warnings |
I did not test without round-up on x86. I will test and let you know the result 👍 |
I didn't use llvm linker. My cpu is core-i5 4300U. CPUs are not comparable. And since linking is single-threaded most probably that's the reason of difference in time. I will try cloudlab and let you know the result |
I see. It's possible that warning is specific to Arm, which I never ran. I can take a brief look |
Does it mean our code has some issue that with LLVM linker it doesn't work ? |
In my own test, it looks like so. Please do verify.
I personally don't want to do that... I believe a lot of alignment in our code is assuming 64-bit. Let's focus on x86_64 and aarch64. For more, let's wait for opinions from the mailing list / Boeing. |
|
I just realize my "fast" builds all happened in an NFS directory; outside it, mine also becomes slow. The full reasoning behind it: Expand/Collapse AI ChatQI am debugging a flaky slow linking problem. For this or that reason, when I build in an NFS, it's fast; otherwise it's slow. I suspect some decisions in Makefiles are different. The script is @build-both.sh . The relevant log is @chat.txt . This is the fast version. In the slow version, some steps around quoted Makefile seems the bottleneck. Analyze why the quoted Makefile part is not run in the fast run. # xen/arch/x86/Makefile
extra-$(XEN_BUILD_PE) += efi.lds
ifeq ($(XEN_BUILD_PE),y)
$(TARGET).efi: $(objtree)/prelink.o $(note_file) $(obj)/efi.lds $(obj)/efi/relocs-dummy.o $(obj)/efi/mkreloc
ifeq ($(CONFIG_DEBUG_INFO),y)
$(if $(filter --strip-debug,$(EFI_LDFLAGS)),echo,:) "Will strip debug info from $(@F)"
endif
$(foreach base, $(VIRT_BASE) $(ALT_BASE), \
$(LD) $(call EFI_LDFLAGS,$(base)) -T $(obj)/efi.lds $< $(relocs-dummy) \
$(objtree)/common/symbols-dummy.o $(note_file_option) \
-o $(dot-target).$(base).0 &&) :
$(MKRELOC) $(foreach base,$(VIRT_BASE) $(ALT_BASE),$(dot-target).$(base).0) \
> $(dot-target).0r.S
$(NM) -pa --format=sysv $(dot-target).$(VIRT_BASE).0 \AI'll search the Xen x86 Makefiles to see how [3 tools called] I'll run a few quick searches in parallel to see how [4 tools called] I'll open the two relevant Makefiles to cite the exact lines that gate [2 tools called] I checked the x86 build rules. The heavy EFI link recipe only runs when Key bits: EFI_LDFLAGS := $(patsubst -m%,-mi386pep,$(LDFLAGS)) --subsystem=10 --enable-long-section-names
LD_PE_check_cmd = $(call ld-option,$(EFI_LDFLAGS) --image-base=0x100000000 -o $(efi-check).efi $(efi-check).o)
XEN_BUILD_PE := $(LD_PE_check_cmd)
...
$(info FINDME FINDME XEN_BUILD_PE=$(XEN_BUILD_PE))What’s happening:
FINDME FINDME XEN_BUILD_PE=y
UPD include/xen/compile.h
if [ -r xen.efi -a -n '/usr/lib64/efi' ]; then \
... install xen.efi ...Status: I inspected the Makefiles and your log. The EFI link block isn’t run in the fast (NFS) build because
Q2What are the downside of not rebuilding EFI? In a non NFS directory, can I also skip it for faster testing? A2
Example (fits your script that runs dist-xen): make CC=/lib/llvm-20/bin/clang -C xen efi-y= dist-xenIf you want to ensure no stale rm -f xen/xen.efi && make CC=/lib/llvm-20/bin/clang -C xen efi-y= dist-xenOptional: you can also set
Q3If I'm going to boot Xen via GRUB, can I skip it? A3
Quick check: look at your GRUB stanza. If it says To skip in non-NFS builds for faster loops: rm -f xen/xen.efi && make CC=/lib/llvm-20/bin/clang -C xen efi-y= dist-xen
Let me see if there is a general way to speed up all x86 builds. make ${MAKE_FLAGS[@]} -j$(nproc) efi-y= dist-xen
sudo make ${MAKE_FLAGS[@]} -j$(nproc) efi-y= install-xenThe current measurement of
|
No description provided.